home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5431 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  33 lines

  1. Newsgroups: comp.lang.c++
  2. Path: nntp.coast.net!torn!nott!cunews!news
  3. From: Alex Fitzpatrick <ug940002@omega.scs.carleton.ca>
  4. Subject: Re: Question on storing a char as an int and retrieving it
  5. X-Nntp-Posting-Host: alpha06.scs.carleton.ca
  6. Content-Type: text/plain; charset=us-ascii
  7. Message-ID: <311518FC.3D61@omega.scs.carleton.ca>
  8. Sender: news@cunews.carleton.ca (News Administrator)
  9. Content-Transfer-Encoding: 7bit
  10. Organization: Carleton University
  11. References: <miller.2.0025DF55@crosslink.net>
  12. Mime-Version: 1.0
  13. Date: Sun, 4 Feb 1996 20:37:16 GMT
  14. X-Mailer: Mozilla 2.0b6b (Win16; I)
  15.  
  16. Randall Miller wrote:
  17. > This might seem like as easy question, but I do need help
  18. > if I read in a char and store it in a stack of integers, I know how to
  19. > output it as a char by using cout.put(), but if I want to pop it off the stack
  20. > and act on it as a char how do I convert it back to a char?
  21.  
  22. Unless I really misunderstood, you can simply use a cast on it.
  23.  
  24. So if your stack has a pop operation that returns an int:
  25.  
  26.     char aChar = (char) theStack.pop();
  27.  
  28. Or did I miss the point?
  29.  
  30. Alex
  31.